<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="~{commons/public1::common-public}">
	<meta charset="UTF-8">
		<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha512-SfTiTlX6kk+qitfevl/7LibUOeJWlt9rbyDn92a1DqWOw9vWG2MFoays0sgObmWazO5BQPiFucnnEAjpAB+/Sw==" crossorigin="anonymous" referrerpolicy="no-referrer" />
		<meta charset="utf-8">
		<title></title>
</head>
		<!-- Favicon -->
		<link rel="shortcut icon" type="image/x-icon" th:href="@{/static/assets/images/favicon.ico}">
		<link rel="stylesheet" th:href="@{/assets/css/vendor/vendor.min.css}">
		<link rel="stylesheet" th:href="@{/assets/css/plugins/plugins.min.css}">
		<link rel="stylesheet" th:href="@{/assets/css/style.min.css}">
	<body>
	<header th:replace="~{commons/header1::common-header}"></header>

<!--		<div class="header-menu header-bottom-area theme-bg" style="height: 55px;">-->
<!--		</div>-->

		<!-- ========================
    Product Details Area Start
    ===========================-->
		<div class="product-area product-details-section" style="background-color: #EFF3F5;padding-top: 35px">
			<div class="container mb-0">
					<div class="col-lg-11 col-12 mt-10" style="background-color: white;box-shadow: 0 0 10px #000;padding-bottom: 20px">
						<div class="row">
							<span></span>
						</div>
						<!-- Product Summery Start -->
						<div class="product-summery position-relative">
							<div class="product-head">
								<h1 class="product-title">[[${forumInfo.getTitle()}]]</h1>
							</div>

							<div class="price-box mt-0">
								<span style="color: darkgray;">[[${forumInfo.getUserName()}]]</span>
								<span style="color: darkgray;">时间：[[${forumInfo.getCreateTime()}]]</span>
							</div>

							<div class="product_desc mt-2">
								<p>[[${forumInfo.getContent()}]]</p>
							</div>

						</div>
						<!-- Product Summery End -->
					</div>
			</div>

			<div class="container">
				<!-- Start Single Review -->
				<div class="col-lg-11 col-12 mt-35" style="background-color: white;box-shadow: 0 0 10px #000;padding-bottom: 20px">
					<form class="layui-form">
					<div class="input-group" style="padding-top: 10px">
							<input type="hidden" name="userId" th:value="${forumInfo.getAdminId()}">
							<input  type="hidden" name="forumId" th:value="${forumInfo.getId()}">
							<input type="text" name="content"  class="form-control" placeholder="请写下您的评论">
							<button type="submit" lay-submit lay-filter="commentTable" class="btn-secondary" style="margin-left: 10px;"><i class="fa fa-edit"></i> 提交评价</button>
					</div>
					</form>

					<div class="col-lg-11 col-sm-9 col-md-10">

						<div class="product-desc-tab-content">
							<div class="review_address_inner mt-20">
								<h1 class="last-title mb-20" style="font-size: 16px">总共已有 [[${forumInfo.getCountComment()}]] 条评论</h1>
							</div>

							<!--Start Single Comment-->
							<div class="col-lg-11 col-sm-9" style="background-color: #EFF3F5;box-shadow: 0 0 5px #000;margin-bottom: 20px;padding-bottom: 10px" th:each="commentInfo: ${commentInfos}">
								<div class="product-thumb pt-2">
									<img th:src="@{/assets/images/blog/comment/comment-3.jpg}" alt="review images">
								</div>
								<form class="layui-form">
								<div class="review_details">
									<div class="review_info">
										<input hidden name="id" th:value="${commentInfo.getId()}">
										<h1 class="last-title">[[${commentInfo.getUserName()}]]</h1>
										<span style="color: darkgray;">时间：[[${commentInfo.getCreateTime()}]]</span>
										<button type="submit" lay-submit lay-filter="deleteComment" class="btn-secondary" style="margin-left: 10px;" th:if="${userInfoId == commentInfo.getUserId()}">删除</button>
									</div>
									<p style="font-size: 15px;color: darkgray">[[${commentInfo.getContent()}]]</p>
								</div>
								</form>
							</div>
							<!--End Single Comment-->

						</div>
					</div>
				</div>
				<!-- End Single Review -->
			</div>
		</div>
		<!-- ========================
        Product Details Area End
        ===========================-->

	<div class="product-area product-details-section" style="background-color: #EFF3F5;padding-top: 150px"></div>

<script th:src="@{/assets/js/vendor/vendor.min.js}"></script>
<script th:src="@{/assets/js/plugins/plugins.min.js}"></script>
<script th:src="@{/assets/js/main.js}"></script>
<script th:src="@{/layuimini/js/lay-module/xm-select/xm-select.js}"></script>
<!-- <script th:src="@{/layuimini/lib/layui-v2.5.5/layui.js}" charset="utf-8"></script> -->
<script th:src="@{/layuimini/js/lay-config.js?v=2.0.0}" charset="utf-8"></script>

<script>
	layui.use(['form'],function (){
		var $ = layui.jquery,
			form = layui.form,
			layer = layui.layer;

		form.on('submit(commentTable)',function (data) {
		
			$.ajax({
				type: 'post',
				url: '/comment/addComment',
				data: data.field,
				dataType: 'json',
				success: function (res){
					if(res.code == 200){
						layer.msg(res.msg,{time: 1000,icon: 1}, function (){
							window.location.reload();

						});
					}else{
						layer.msg(res.msg,{time: 2000,icon: 2});
					}
				},
				error: function (res){
					layer.msg('请求失败',{time: 2000,icon: 2});
				}
			});
			return false;
		});

		 form.on('submit(deleteComment)',function (data) {
			$.ajax({
				type: 'post',
				url: '/comment/delCommentByUser',
				data: data.field,
				dataType: 'json',
				success: function (res){
					if(res.code == 200){
						layer.msg(res.msg,{time: 1000,icon: 1}, function (){
							window.location.reload();
						});
					}else{
						layer.msg(res.msg,{time: 2000,icon: 2});
					}
				},
				error: function (res){
					console.log(data);
					layer.msg('请求失败',{time: 2000,icon: 2});
				}
			});
			return false;
		}); 
	})
</script>
</body>

</html>